{extends file="index.tpl"}
{block name="page-content"}

<script type="text/javascript">
$(document).ready(function()
{
	$(".edit_tr").click(function()
	{
		var ID=$(this).attr('id');
		$("#gamecategory_"+ID).hide();
		$("#cuphapdau_"+ID).hide();
		$("#cuphapcuoi_"+ID).hide();
		$("#dauso_"+ID).hide();
		
		$("#gamecategory_input_"+ID).show();
		$("#cuphapdau_input_"+ID).show();
		$("#cuphapcuoi_input_"+ID).show();
		$("#dauso_input_"+ID).show();
	}).change(function()
	{
		var ID=$(this).attr('id');
		var gamecategory=$("#gamecategory_input_"+ID).val();
		var cuphapdau=$("#cuphapdau_input_"+ID).val();
		var cuphapcuoi=$("#cuphapcuoi_input_"+ID).val();
		var dauso=$("#dauso_input_"+ID).val();
		
		var dataString = 'id='+ ID +'&gamecategory='+gamecategory+'&cuphapdau='+cuphapdau+'&cuphapcuoi='+cuphapcuoi+'&dauso='+dauso+'&database={if isset($data)}{$data}{else}tpg{/if}';
		
		$("#gamecategory_"+ID).html('<img src="http://thanhphogame.com/admin/view/img/load.gif" />');
		$("#cuphapdau_"+ID).html('<img src="http://thanhphogame.com/admin/view/img/load.gif" />');
		$("#cuphapcuoi_"+ID).html('<img src="http://thanhphogame.com/admin/view/img/load.gif" />');				
		$("#dauso_"+ID).html('<img src="http://thanhphogame.com/admin/view/img/load.gif" />');
		
		$.ajax({
			type: "POST",
			url: 'http://thanhphogame.com/admin/controller/process/ajaxEditTableGameMessage.php',
			data: dataString,
			cache: false,
			success: function(html)
			{
				$("#gamecategory_"+ID).html(gamecategory);
				$("#cuphapdau_"+ID).html(cuphapdau);
				$("#cuphapcuoi_"+ID).html(cuphapcuoi);
				$("#dauso_"+ID).html(dauso);
			}
		});		
	});
	
	$(".editbox").mouseup(function() {
		return false
	});
	
	$(document).mouseup(function(){
		$(".editbox").hide();
		$(".text").show();
	});

});
</script>

{literal}
<style>
	.editbox
	{
		display:none;
	}
	.editbox
	{
		font-size:14px;
		width: 70px;
		background-color:#ffffcc;
		border:solid 1px #000;
		padding:4px;
	}
	.edit_tr:hover
	{
		background:url(http://thanhphogame.com/admin/view/img/edit.png) right no-repeat #80C8E5;
		cursor:pointer;
	}

</style>
{/literal}

<div class="row-fluid">
    <div class="span12">
        <div class="block">
        	<div class="row-form">
                <form method="POST" action="{$WEB_BASE_URL}/index.php?controller=gameMessage&action=list&database={if isset($data)}{$data}{else}tpg{/if}&filter=filterGame">
					<div class="span3">
						<select name="filter" class="select" style="width: 100%;"> 
							{foreach from=$gameCategoryArr item=gameCategory}
							<option value="{$gameCategory.id}" {if isset($filter)}{if $gameCategory.id eq $filter}Selected{/if}{/if}>{$gameCategory.name}</option>	
							{/foreach}
							<option value="5"></option>
						</select>
					</div>&nbsp;&nbsp;&nbsp;
					<button class="btn btn-primary" type="submit">&nbsp;&nbsp;&nbsp;&nbsp;Fillter&nbsp;&nbsp;&nbsp;&nbsp;</button>
                </form>
			</div>
			<div class="btn-group" data-toggle="buttons-checkbox">
				<table>
					<tr>
						<td>
							<form method="POST" action="{$WEB_BASE_URL}/index.php?controller=gameMessage&action=list&database=tpg">
								<button type="submit" class="btn btn-primary {if isset($data) && $data eq 'tpg'}active{/if}">Thành Phố Game</button>
							</form>
						</td>
						<td>
							<form method="POST" action="{$WEB_BASE_URL}/index.php?controller=gameMessage&action=list&database=cgmb">
								<button type="submit" class="btn btn-primary {if isset($data) && $data eq 'cgmb'}active{/if}">Chơi Game Mobi</button>
							</form>
						</td>
						<td>
							<form method="POST" action="{$WEB_BASE_URL}/index.php?controller=gameMessage&action=list&database=mmbg">
								<button type="submit" class="btn btn-primary {if isset($data) && $data eq 'mmbg'}active{/if}" >My Mobi Game</button>
							</form>
						</td>
						<td>
							<form method="POST" action="{$WEB_BASE_URL}/index.php?controller=gameMessage&action=list&database=nsgt">
								<button type="submit" class="btn btn-primary {if isset($data) && $data eq 'nsgt'}active{/if}" >Ngôi Sao Game Thủ</button>
							</form>
						</td>
						<td>
							<form method="POST" action="{$WEB_BASE_URL}/index.php?controller=gameMessage&action=add">
								<button type="submit" class="btn btn-primary" >Thêm Game Message</button>
							</form>
						</td>
						<td>
							<form method="POST" action="{$WEB_BASE_URL}/index.php?controller=gameMessage&action=addMMBG">
								<button type="submit" class="btn btn-warring" >Thêm Game Message MyMobiGame</button>
							</form>
						</td>
					</tr>
				</table>
			</div>
            <div class="head dblue">
                <div class="icon"><span class="ico-layout-9"></span></div>
                <h2>Danh Sách Game Message</h2>
                <ul class="buttons">
                    <li><a href="#" onClick="source('table_sort_pagination'); return false;">
                        <div class="icon"><span class="ico-info"></span></div>
                    </a></li>
                </ul>
            </div>
            <div class="data-fluid">
                <table class="table lcnp" id="listGame" cellpadding="0" cellspacing="0" width="100%">
                    <thead>
                        <tr>
                            <th width="10%"><input type="checkbox" class="checkall" /></th>
                            <th width="10%">ID</th>
                            <th width="20%">Game Category Name</th>
                            <th width="10%">Cú Pháp Đầu</th>
                            <th width="10%">Cú Pháp Sau</th>
                            <th width="10%">Đầu Số</th>
                            <th width="10%" class="TAC">Actions</th>
                        </tr>
                    </thead>
                    <tbody>
                   	{if isset($gameMessArr)}
                    {foreach from=$gameMessArr item=gameMessage}
                        <tr id="{$gameMessage.id}" class="edit_tr">
                            <td><input type="checkbox" name="order[]" value="528" /></td>
                            <td>{$gameMessage.id}</td>
                            <td>
                            	<span id="gamecategory_{$gameMessage.id}" class="text">
                            		{if $gameMessage.game_category_id ge 1}{$gameMessage.game_name}{else}0{/if}
                            	</span>
                            	<select name="game_category_id" class="editbox" id="gamecategory_input_{$gameMessage.id}" style="display: none;">
									<option value="0">-- Chọn Game Category Name --</option>
									{foreach from=$gameCategoryArr item=gameCategory}
									<option value="{$gameCategory.id}" {if $gameCategory.id eq $gameMessage.game_category_id}Selected{/if}>{$gameCategory.name}</option>
									{/foreach}
								</select>
                            </td>
                            <td>
                            	<span id="cuphapdau_{$gameMessage.id}" class="text">
                            		{$gameMessage.cu_phap_dau}
                            	</span>
                            	<select name="game_category_id" class="editbox" id="cuphapdau_input_{$gameMessage.id}" style="display: none;">
									<option value="TG" {if $gameMessage.cu_phap_dau eq 'TG'}Selected{/if}>TG</option>
									<option value="TAI mmg" {if $gameMessage.cu_phap_dau eq 'TAI mmg'}Selected{/if}>TAI mmg</option>
									<option value="VIPLAY" {if $gameMessage.cu_phap_dau eq 'VIPLAY'}Selected{/if}>VIPLAY</option>
								</select>
                            </td>
                            <td>
                            	<span id="cuphapcuoi_{$gameMessage.id}" class="text">
                            		{$gameMessage.cu_phap_cuoi}
                            	</span>
                            	<input type="text" value="{$gameMessage.cu_phap_cuoi}" class="editbox" id="cuphapcuoi_input_{$gameMessage.id}" style="display: none;"/>
                            </td>
                            <td>
                            	<span id="dauso_{$gameMessage.id}" class="text">
                            		{$gameMessage.dau_so}
                            	</span>
                            	<select name="game_category_id" class="editbox" id="dauso_input_{$gameMessage.id}" style="display: none;">
									<option value="6086" {if $gameMessage.dau_so eq '6068'}Selected{/if}>6086</option>
									<option value="8100" {if $gameMessage.dau_so eq '8100'}Selected{/if}>8100</option>
									<option value="8075" {if $gameMessage.dau_so eq '8075'}Selected{/if}>8075</option>
								</select>
                            </td>
                            <td>
                                <a href="{$WEB_BASE_URL}/index.php?controller=gameMessage&action=update&database={if isset($data)}{$data}{else}tpg{/if}&id={$gameMessage.id}" class="button green">
                                    <div class="icon"><span class="ico-pencil"></span></div>
                                </a>
                                <a href="{$WEB_BASE_URL}/index.php?controller=gameMessage&action=delete&database={if isset($data)}{$data}{else}tpg{/if}&id={$gameMessage.id}" class="button red" onclick="return confirm('Bạn có muốn xóa tiếp không?')">
                                    <div class="icon"><span class="ico-remove"></span></div>
                                </a>
                            </td>
                        </tr>
                    {/foreach}
                    {/if}
                    </tbody>
                </table>
                <div class="pagination pagination-centered">
                       {if isset($pageFirst) && isset($pagePrev) && isset($pageList) && isset($pageNext) && isset($pageLast)}
	                	<ul>
	                		<li class="disabled">{$pageFirst}</li>
	                		<li class="active">{$pagePrev}</li>
	                		<li>{$pageList}</li>
	                		<li>{$pageNext}</li>
	                		<li>{$pageLast}</li>
	                    </ul>
	                    {/if}
                    </div>
            </div>
        </div>
    </div>
</div>

{/block}
